package com.ruoyi.carUser.service.imp;

import com.ruoyi.carUser.domain.UserMerchant;
import com.ruoyi.carUser.mapper.MerchantUserMapper;
import com.ruoyi.carUser.service.WashCarService;
import com.ruoyi.system.api.domain.OrderEvaluation;
import com.ruoyi.system.api.domain.ServiceDetails;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;
@Service
public class WashCarServiceImpl implements WashCarService {
    @Autowired
    private MerchantUserMapper merchantUserMapper;

    @Override
    public List<UserMerchant> selectUserMerchantList(UserMerchant userMerchant) {
        System.out.println(userMerchant);
        List<UserMerchant> userMerchants = merchantUserMapper.selectUserMerchantList(userMerchant);
        List<UserMerchant> countList = merchantUserMapper.selectCount(userMerchant);
        for (UserMerchant userMerchant1 : userMerchants) {
            for (UserMerchant userMerchant2 : countList) {
                if (userMerchant1.getMerchantId() == userMerchant2.getMerchantId()) {
                    userMerchant1.setCount(userMerchant2.getCount());
                    break;
                }
            }
        }
        return userMerchants;
    }

    @Override
    public List<ServiceDetails> getServiceDetails(UserMerchant userMerchant) {
        return merchantUserMapper.getServiceDetails(userMerchant);
    }

    @Override
    public List<OrderEvaluation> getEvaluationList(UserMerchant userMerchant) {
        return merchantUserMapper.getEvaluationList(userMerchant);
    }
}
